package com.siyuanren.gcocp.mapper;

import com.siyuanren.gcocp.dto.TemplateMsgDTO;
import com.siyuanren.gcocp.entity.WxCourse;
import com.siyuanren.gcocp.entity.WxUser;

import java.util.List;

/**
 * Created by   anxing
 * Project_name gcocp-parent
 * Path         com.siyuanren.gcocp.mapper
 * Date         2018/6/21
 * Time         16:02
 * Description
 */
public interface MyTaskMapper {

    /**
     * 返回还有用户需要学习
     * SELECT DISTINCT u.* FROM wx_user u, wx_user_course uc, wx_course_start cs, wx_course c
     WHERE u.id = uc.`user_id` AND uc.`course_start_id` = cs.id  AND uc.`course_id` = c.`id`
     AND TO_DAYS(NOW()) - TO_DAYS(cs.`start_time`) < c.`chapter_count`
     */
    public List<WxUser> getUserNeedToStudy();

    /**
     * 返回用户正在学习的课程
     * @param userId
     * @return
     * SELECT c.* FROM wx_course c, wx_user_course uc, wx_course_start cs
    WHERE uc.user_id=1 AND uc.`course_id`=c.id AND uc.`course_start_id`=cs.`id`
    AND TO_DAYS(NOW()) - TO_DAYS(cs.`start_time`) < c.`chapter_count`
    AND TO_DAYS(NOW()) - TO_DAYS(cs.`start_time`) >= 0
     */
    public List<WxCourse> getStudingCourse(Integer userId);

    /**
     * 返回指定时间的模板消息
     * @param sendTime
     * @return
     * SELECT ut.id task_id, ut.`user_open_id`, tm.* FROM wx_template_msg tm, wx_user_timer_task ut
    WHERE ut.`available`=1 AND ut.`send_time`=7
    AND TO_DAYS(NOW()) >= TO_DAYS(ut.`start_date`)
    AND TO_DAYS(NOW()) <= TO_DAYS(ut.`end_date`)
    AND ut.`template_msg_id` = tm.`id`
    AND TO_DAYS(ut.`last_send_date`) <> TO_DAYS(NOW());
     */
    List<TemplateMsgDTO> getTemplateMsg(int sendTime);
}


